<!-- 添加管理员 -->
<template>
  <div class="add-user">
    <div class="header">添加管理员</div>
    <el-form label-width="100px">
      <el-form-item label="账号">
        <el-input v-model="form.account" placeholder="请输入账号"></el-input>
      </el-form-item>
      <el-form-item label="昵称">
        <el-input v-model="form.nickname" placeholder="请输入昵称"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="form.pwd" placeholder="请输入密码" type="password"></el-input>
      </el-form-item>
      <el-form-item label="手机号">
        <el-input v-model="form.phone" placeholder="请输入手机号"></el-input>
      </el-form-item>
      <el-form-item label="角色">
        <el-select v-model="form.user_role" placeholder="请选择角色">
          <el-option :label="v" :value="k" v-for="(v,k) in role" :key="k"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="状态">
        <el-select v-model="form.status" placeholder="请选择状态">
          <el-option :label="v.name" :value="v.status" v-for="(v,k) in statusInfo" :key="k"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <router-link to="/dashboard/system/user">
          <el-button>返回</el-button>
        </router-link>
        <el-button @click="addUser" type="primary">添加</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import systemUser from '@/mixins/systemUser'
export default {
  mixins:[systemUser],
  data() {
    return {
      form: {
        nickname: "",
        account: "",
        pwd: "",
        phone: "",
        status: "",
        user_role: ""
      },
      statusInfo: [
        {
          name: "待激活",
          status: "0"
        },
        {
          name: "正常",
          status: "1"
        },
        {
          name: "已锁定",
          status: "2"
        },
        {
          name: "已停用",
          status: "3"
        },
        {
          name: "已注销",
          status: "4"
        }
      ],
      role: ["超级管理员", "销售总监", "销售经理", "普通员工", "客服"]
    };
  },
  created() {},
  methods: {
    addUser() {
      //添加管理员
      // console.log(this.form)
      this.$http.addSystemUser(this.form).then(res => {
        console.log(res);
        let tips = res.data.msg;
        if (res && res.data.code == 200) {
          this.$message({
            type: 'success',
            message: tips
          });
          this.$router.push('/dashboard/system/user/list')
          this.load()
        }
      });
    }
  }
};
</script>

<style scoped lang="less">
.add-user {
  background: #fff;
  .header {
    padding: 15px 0 15px 20px;
    border-bottom: 1px solid #eee;
  }
  .el-form {
    padding: 20px;
    padding-left: 200px;
    .el-form-item {
      .el-input {
        width: 60%;
      }
    }
    .el-select {
      width: 40%;
    }
  }
}
</style>
